<template>
  <div class="news-header__container">
    <!-- 新闻来源logo，支持加载失败显示默认图标 -->
    <img 
      v-if="sourceLogo"
      :src="sourceLogo"
      :alt="sourceType"
      class="news-header__logo"
    >
    <!-- 新闻来源名称 -->
    <span class="news-header__name">{{ sourceType }}</span>
  </div>
</template>

<script>
export default {
  name: 'NewsHeader',
  props: {
    sourceLogo: {
      type: String,
      default: ''
    },
    sourceType: {
      type: String,
      required: true,
      validator: value => value.length <= 20
    }
  },
  methods: {
  }
}
</script>

<style lang="scss" scoped>
@import '@/styles/mixin.scss';

.news-header__container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  margin: 4px 0;
  background-color: #fff;
  border-radius: 8px;
  transition: all 0.2s ease;

  &:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
  }
}

.news-header__logo {
  height: 40px;
  width: 40px;
  border: 1px solid #ebeef5;
  border-radius: 50%;
  object-fit: cover;
  transition: transform 0.2s ease;

  &:hover {
    transform: scale(1.05);
  }
}

.news-header__name {
  font-size: 15px;
  font-weight: 600;
  color: #303133;
  @include text-ellipsis;
  transition: color 0.2s ease;

  &:hover {
    color: #409eff;
  }
}
</style>
